import java.net.URLDecoder;
import java.net.URLEncoder;


public class EncodeTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {

//		encodeDecodeTest();
		
		encodeTest();
		

	}

	private static void encodeTest() throws Exception {
		String str = "TestImage  - 33.tif";
		System.out.println("string: " + str);
		System.out.println("Encoded: " + URLEncoder.encode(str, "UTF-8"));
		System.out.println("-------------------------");
		
		str = "TestImage++-+33.tif";
		System.out.println("string: " + str);
		System.out.println("Encoded: " + URLEncoder.encode(str, "UTF-8"));
		System.out.println("-------------------------");
	}
	
	private static void encodeDecodeTest() throws Exception {
		
		String escapedByJavascript = "S%3A/V3WebImage_Storage/strso/qa/released/Copy%20of%202.tif";
		System.out.println("escaped by javascript: " + escapedByJavascript);
		System.out.println("decoded by java: " + URLDecoder.decode(escapedByJavascript));
		System.out.println();
		
		String encodedByJavascript = "S:/V3WebImage_Storage/strso/qa/released/Copy%20of%202.tif";
		System.out.println("encoded by javascript: " + encodedByJavascript);
		System.out.println("decoded by java: " + URLDecoder.decode(encodedByJavascript));
		System.out.println();
		
		String str = "S:/V3WebImage_Storage/strso/qa/released/Copy of 2.tif";
		System.out.println("string: " + str);
		System.out.println("encoded by java: " + URLEncoder.encode(str, "UTF-8"));
		
	}
}
